var t = require("../../0E8B0BC42FB173BF68ED63C34BB4DCA6.js"), e = require("../../30A2BE152FB173BF56C4D61233F4DCA6.js"), i = require("../../A7DBB9B62FB173BFC1BDD1B19505DCA6.js"), s = wx.createInnerAudioContext();

Page({
    data: {
        isx: /iphone10|iphone x/i.test(wx.getSystemInfoSync().model),
        isAndroid: /android/i.test(wx.getSystemInfoSync().system),
        pokerList: [],
        curPoker: "",
        curIndex: 52,
        drawAnimation: "",
        showAnimation: "",
        drawedList: new Array(),
        miniDrawedList: new Array(),
        hisList: new Array(),
        showPoker: !1,
        showHis: !1,
        punish: {},
        pokerNumber: [ "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" ],
        showSetting: !1,
        resultPoker: "",
        showResult: !1,
        showRefresh: !1,
        punishment: null,
        punishShuffle: [],
        currentPages: 1,
        openSetting: !1
    },
    onLoad: function(t) {
        this.init(), s.src = "/mp3/poker.mp3", this.setData({
            currentPages: getCurrentPages().length
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function(i) {
        return {
            title: e(t.SHARE.title)[0],
            path: "/pages/index/index",
            imageUrl: "/assets/" + e(t.SHARE.image)[0]
        };
    },
    init: function() {
        var i = t.POKEY_LIST;
        i = e(i), i = e(i), i = e(i);
        var s = new Array();
        s.push("back"), s.push("back"), s.push("back"), s.push("back"), s.push("back"), 
        s.push("back"), this.initPunishment(), this.setData({
            pokerList: i,
            drawedList: s,
            miniDrawedList: s,
            curIndex: 52,
            hisList: new Array()
        });
    },
    initPunishment: function() {
        var i = getApp().globalData.pokerPunishment;
        console.log("pokerPunishment:", i);
        var s = e(t.MEASURES.drink), n = e(t.MEASURES.truth), a = e(t.MEASURES.risk), o = [];
        if (i.drink && s.forEach(function(t) {
            if ("抽中三次免单" === t || "抽中三次买单" === t) ; else {
                var e = {
                    type: "drink",
                    title: t
                };
                o.push(e);
            }
        }), i.truth && n.forEach(function(t) {
            var e = {
                type: "truth",
                title: t
            };
            o.push(e);
        }), i.risk && a.forEach(function(t) {
            var e = {
                type: "risk",
                title: t
            };
            o.push(e);
        }), o.length < 52) {
            var r = o;
            if (console.log("punishShuffle length:", o.length), (o = o.concat(r)).length < 52) {
                var h = o;
                o = o.concat(h);
            }
        }
        (o = e(o)).length > 60 && (o = o.slice(0, 56)), console.log("punishShuffle:", o), 
        this.setData({
            punishShuffle: o
        });
    },
    drawCard: function(t) {
        var e = this.data.pokerList, i = this.data.curIndex - 1, n = this.data.drawedList, a = e.pop(), o = a, r = (a.substr(2), 
        this.data.punishShuffle[i]);
        n.push(a), this.setData({
            pokerList: e,
            drawedList: n,
            showPoker: !0
        }), s.play();
        var h = this;
        setTimeout(function() {
            var t = wx.createAnimation({
                duration: 300,
                timingFunction: "ease",
                delay: 0,
                transformOrigin: "50% 50%"
            });
            t.translateY(-25).step(), h.setData({
                drawAnimation: t.export()
            });
            var e = wx.createAnimation({
                duration: 1,
                timingFunction: "linear",
                delay: 0,
                transformOrigin: "50% 50% 0"
            });
            e.scale(.1, .1).opacity(0).step(), h.setData({
                curIndex: i,
                showResult: !0,
                showAnimation: e.export(),
                resultPoker: "back"
            });
        }, 100), setTimeout(function() {
            var t = wx.createAnimation({
                duration: 100,
                timingFunction: "linear",
                delay: 0,
                transformOrigin: "50% 50% 0"
            });
            t.opacity(1).scale(.1, .1).rotate(-180).step(), t.scale(.2, .2).rotate(0).step(), 
            t.scale(.3, .3).rotate(-180).step(), t.scale(.4, .4).rotate(0).step(), t.scale(.5, .5).rotate(-180).step(), 
            t.scale(.6, .6).rotate(0).step(), t.scale(.7, .7).rotate(-180).step(), t.scale(.8, .8).rotate(0).step(), 
            t.scale(.9, .9).rotate(-180).step(), t.scale(1, 1).rotate(0).step(), h.setData({
                curPoker: "",
                resultPoker: o,
                showAnimation: t.export(),
                showPoker: !1
            });
        }, 400), setTimeout(function() {
            h.setData({
                punishment: r
            });
        }, 2e3);
    },
    showHis: function() {
        var t = this.data.drawedList.length, e = this.data.hisList;
        t > 6 && (e = this.data.drawedList.slice(6)), this.setData({
            hisList: e,
            showHis: !0
        });
    },
    closePop: function() {
        this.setData({
            showHis: !1
        });
    },
    refresh: function() {
        this.setData({
            showRefresh: !0
        });
    },
    refreshCancle: function() {
        this.setData({
            showRefresh: !1
        });
    },
    refreshConfirm: function() {
        this.init(), this.setData({
            showRefresh: !1
        });
    },
    closeResult: function() {
        var t = this.data.drawedList.length, e = this.data.drawedList.slice(t - 6);
        this.setData({
            miniDrawedList: e,
            showResult: !1,
            punishment: null
        });
    },
    back: function() {
        i.navigateBack();
    },
    changeSetting: function(t) {
        console.log("changeSetting:", t), this.setData({
            openSetting: !1
        }), this.init();
    },
    openSetting: function() {
        console.log("openSetting"), this.setData({
            openSetting: !0
        });
    }
});